package com.xgz.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xgz.dao.TRoleDao;
import com.xgz.entity.MyPage;
import com.xgz.entity.TRole;
import com.xgz.entity.TUser;
import com.xgz.service.TRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class TRoleServiceImpl implements TRoleService {
    @Autowired
    private TRoleDao tRoleDao;

    @Override
    public PageInfo findAll(MyPage myPage) {
        PageHelper.startPage(myPage.getPage(),myPage.getLimit());
        return new PageInfo(tRoleDao.selectAll());
    }

    /**
     * 查询所有数据
     * @param myPage
     * @param tRole
     * @return
     */
    @Override
    public PageInfo queryAll(MyPage myPage, TRole tRole) {
        PageHelper.startPage(myPage.getPage(), myPage.getLimit());
        PageInfo pageInfo = new PageInfo(tRoleDao.selectAll());
        return pageInfo;
    }

    @Override
    public Boolean delOne(TRole tRole) {
        List<TRole> tRoles = tRoleDao.queryOne(tRole.getRid());
        int i=-1;
        if (tRoles.isEmpty()){
            i = tRoleDao.delOne(tRole);
        }
        return i>0;
    }




}
